import 'package:gluz/generated/json/base/json_convert_content.dart';
import 'package:gluz/app/data/user_profile_entity.dart';
import 'package:get/get.dart';

import 'package:gluz/app/data/user_vip_entity.dart';

import '../../app_session.dart';


TokenEntity $TokenEntityFromJson(Map<String, dynamic> json) {
  final TokenEntity tokenEntity = TokenEntity();
  final String? accessToken = jsonConvert.convert<String>(json['access_token']);
  if (accessToken != null) {
    tokenEntity.accessToken = accessToken;
  }
  final int? expireIn = jsonConvert.convert<int>(json['expire_in']);
  if (expireIn != null) {
    tokenEntity.expireIn = expireIn;
  }
  return tokenEntity;
}

Map<String, dynamic> $TokenEntityToJson(TokenEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['access_token'] = entity.accessToken;
  data['expire_in'] = entity.expireIn;
  return data;
}

extension TokenEntityExtension on TokenEntity {
  TokenEntity copyWith({
    String? accessToken,
    int? expireIn,
  }) {
    return TokenEntity()
      ..accessToken = accessToken ?? this.accessToken
      ..expireIn = expireIn ?? this.expireIn;
  }
}

UserProfileEntity $UserProfileEntityFromJson(Map<String, dynamic> json) {
  final UserProfileEntity userProfileEntity = UserProfileEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    userProfileEntity.id = id;
  }
  final String? countryCode = jsonConvert.convert<String>(json['countryCode']);
  if (countryCode != null) {
    userProfileEntity.countryCode = countryCode;
  }
  final String? phoneNumber = jsonConvert.convert<String>(json['phoneNumber']);
  if (phoneNumber != null) {
    userProfileEntity.phoneNumber = phoneNumber;
  }
  final String? country = jsonConvert.convert<String>(json['country']);
  if (country != null) {
    userProfileEntity.country = country;
  }
  final String? nickName = jsonConvert.convert<String>(json['nickName']);
  if (nickName != null) {
    userProfileEntity.nickName = nickName;
  }
  final int? areaId = jsonConvert.convert<int>(json['areaId']);
  if (areaId != null) {
    userProfileEntity.areaId = areaId;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    userProfileEntity.avatar = avatar;
  }
  final String? identity = jsonConvert.convert<String>(json['identity']);
  if (identity != null) {
    userProfileEntity.identity = identity;
  }
  final String? status = jsonConvert.convert<String>(json['status']);
  if (status != null) {
    userProfileEntity.status = status;
  }
  final String? authStatus = jsonConvert.convert<String>(json['authStatus']);
  if (authStatus != null) {
    userProfileEntity.authStatus = authStatus;
  }
  final dynamic rejectReason = json['rejectReason'];
  if (rejectReason != null) {
    userProfileEntity.rejectReason = rejectReason;
  }
  final String? authType = jsonConvert.convert<String>(json['authType']);
  if (authType != null) {
    userProfileEntity.authType = authType;
  }
  final String? createTime = jsonConvert.convert<String>(json['createTime']);
  if (createTime != null) {
    userProfileEntity.createTime = createTime;
  }
  final String? productSwitch = jsonConvert.convert<String>(
      json['productSwitch']);
  if (productSwitch != null) {
    userProfileEntity.productSwitch = productSwitch;
  }
  final UserVipEntity? vipEntity = jsonConvert.convert<UserVipEntity>(
      json['vipEntity']);
  if (vipEntity != null) {
    userProfileEntity.vipEntity = vipEntity;
  }
  return userProfileEntity;
}

Map<String, dynamic> $UserProfileEntityToJson(UserProfileEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['countryCode'] = entity.countryCode;
  data['phoneNumber'] = entity.phoneNumber;
  data['country'] = entity.country;
  data['nickName'] = entity.nickName;
  data['areaId'] = entity.areaId;
  data['avatar'] = entity.avatar;
  data['identity'] = entity.identity;
  data['status'] = entity.status;
  data['authStatus'] = entity.authStatus;
  data['rejectReason'] = entity.rejectReason;
  data['authType'] = entity.authType;
  data['createTime'] = entity.createTime;
  data['productSwitch'] = entity.productSwitch;
  data['vipEntity'] = entity.vipEntity.toJson();
  return data;
}

extension UserProfileEntityExtension on UserProfileEntity {
  UserProfileEntity copyWith({
    String? id,
    String? countryCode,
    String? phoneNumber,
    String? country,
    String? nickName,
    int? areaId,
    String? avatar,
    String? identity,
    String? status,
    String? authStatus,
    dynamic rejectReason,
    String? authType,
    String? createTime,
    String? productSwitch,
    UserVipEntity? vipEntity,
  }) {
    return UserProfileEntity()
      ..id = id ?? this.id
      ..countryCode = countryCode ?? this.countryCode
      ..phoneNumber = phoneNumber ?? this.phoneNumber
      ..country = country ?? this.country
      ..nickName = nickName ?? this.nickName
      ..areaId = areaId ?? this.areaId
      ..avatar = avatar ?? this.avatar
      ..identity = identity ?? this.identity
      ..status = status ?? this.status
      ..authStatus = authStatus ?? this.authStatus
      ..rejectReason = rejectReason ?? this.rejectReason
      ..authType = authType ?? this.authType
      ..createTime = createTime ?? this.createTime
      ..productSwitch = productSwitch ?? this.productSwitch
      ..vipEntity = vipEntity ?? this.vipEntity;
  }
}